home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
-
- main.c
-
- This file contains the main code and initialization routines for
- the QuickDraw GX unaware sample, "Simple Sample."
-
- Additional info can be found in the related develop #19 article,
- "Adding QuickDraw GX Printing to QuickDraw Applications."
-
- Dave Hersey, Apple Developer Technical Support.
-
- ——————— Edit Trail ———————
-
- creation: 1/22/94 - dmh
- cleaned up for 2nd draft of develop article: 3/10/94 - dmh
- cleaned up for final: 4/14/94 - dmh
-
- *********************************************************************/
-
- #include "Simple Sample.h"
-
- Rect gWindowRect = {50, 15, 512, 510}; // Our window size.
- short gAppResRefNum; // Our app's resource file refNum.
- long gSleep = 0; // Sleep value for WaitNextEvent.
- Boolean gQuitAfterPrinting = true; // Quit after handling 'pdoc'?
- Boolean gQuitting; // Quitting?
- Boolean gSystemSevenIsPresent; // System 7.0 or later is available?
-
-
- /************************************************************
- MyInitialize - This routine performs the standard Mac
- toolbox initialization.
-
- *************************************************************/
-
- void MyInitialize()
- {
- CursHandle theCurs;
- Handle menuBar;
-
- // We're not quitting, and we don't have a print dialog displayed.
-
- gQuitting = false;
-
- // Initialize.
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- InitCursor();
-
- /*
- See what system software is available. If we don't have
- what we need, bail.
- */
- MyCheckConfig();
-
- if (!gSystemSevenIsPresent)
- {
- Alert(r_BadConfig, nil);
- gQuitting = true;
- return;
- }
-
- /*
- Change to a watch cursor while we set up our menu bar
- and then install our AppleEvent handlers.
- */
- theCurs = GetCursor(watchCursor);
- SetCursor(*theCurs);
-
- menuBar = GetNewMBar(rMenuBar);
-
- if (menuBar)
- {
- SetMenuBar(menuBar);
- DisposHandle(menuBar);
- AddResMenu(GetMHandle(mApple), 'DRVR');
- DrawMenuBar();
- SetCursor(&qd.arrow);
-
- MyDoAEInstallation();
- }
- }
-
-
- /************************************************************
- MyCheckConfig - This routine sets up our global
- configuration variables based on results from Gestalt.
-
- *************************************************************/
-
- void MyCheckConfig()
- {
- long sysVersion;
-
- // Get the system version and see if it's 7.0 or later.
-
- gSystemSevenIsPresent = false;
-
- if (Gestalt(gestaltSystemVersion, &sysVersion) == noErr)
- if (sysVersion >= 0x0700) gSystemSevenIsPresent = true;
- }
-
-
- /************************************************************
- main - This is our main routine. Not much else to say…
-
- *************************************************************/
-
- void main()
- {
- WindowPtr wind;
- char i;
-
- gAppResRefNum = CurResFile();
- MaxApplZone();
- for (i = 1; i <= 6; i++)
- MoreMasters();
-
- // Initialize the managers and jump into our event loop.
-
- MyInitialize();
-
- while (!gQuitting)
- MyEventLoop();
-
- // Leaving. Close all the windows we opened.
-
- while (wind = FrontWindow())
- MyDisposeDocument(MyGetDocPtr(wind));
- }
-